package com.ssy.lingxi.member.merchant.serviceimpl.feign;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.config.ServiceConfig;
import com.ssy.lingxi.member.merchant.service.feign.IScheduleFeignService;
import com.ssy.lingxi.scheduler.api.feign.ScheduleTaskFeign;
import com.ssy.lingxi.scheduler.api.model.ScheduleTaskVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 调用定时服务feign服务类
 * @author yzc
 * @version 2.0.0
 * @date 2021/8/3
 */
@Service
public class ScheduleFeignServiceImpl implements IScheduleFeignService {

    private static final Logger log = LoggerFactory.getLogger(ScheduleFeignServiceImpl.class);

    @Resource
    private ScheduleTaskFeign scheduleTaskFeign;

    @Override
    public Wrapper<Long> createScheduleTask(List<Long> dataIdList, Long execTime, String callBackUrl, Map<String, Object> taskAttributes, Long memberId, Long roleId) {
        ScheduleTaskVO scheduleTaskVO = new ScheduleTaskVO();
        scheduleTaskVO.setServiceName(ServiceConfig.MERCHANT_MEMBER_SERVICE);
        scheduleTaskVO.setCallbackUrl(callBackUrl);
        scheduleTaskVO.setMemberId(memberId);
        scheduleTaskVO.setRoleId(roleId);
        scheduleTaskVO.setDataIds(dataIdList);
        scheduleTaskVO.setExecTime(execTime);
        scheduleTaskVO.setTaskAttributes(taskAttributes);
        return scheduleTaskFeign.createScheduleTask(scheduleTaskVO);
    }
}
